// pages/profile/profile.ts
const Navigation = require('../../utils/navigation.js')

Page({
  data: {
    currentTime: '09:50',
    userInfo: {
      name: '微信用户3708',
      avatar: '👤',
      memberLevel: '普通用户'
    },
    menuItems: [
      {
        id: 'resources',
        name: '我的资源',
        icon: '📁'
      },
      {
        id: 'team',
        name: '我的团队',
        icon: '👥'
      },
      {
        id: 'wallet',
        name: '我的钱袋',
        icon: '💰'
      },
      {
        id: 'favorites',
        name: '我的收藏',
        icon: '⭐'
      },
      {
        id: 'help',
        name: '帮助中心',
        icon: '😊'
      },
      {
        id: 'contact',
        name: '联系我们',
        icon: '💬'
      }
    ]
  },

  onLoad() {
    this.updateTime();
  },

  onShow() {
    this.updateTime();
  },

  updateTime() {
    const now = new Date();
    const time = now.getHours().toString().padStart(2, '0') + ':' + 
                 now.getMinutes().toString().padStart(2, '0');
    this.setData({
      currentTime: time
    });
  },

  onMenuTap(e: any) {
    const menuId = e.currentTarget.dataset.menu;
    const menuItem = this.data.menuItems.find(item => item.id === menuId);
    
    if (menuItem) {
      wx.showToast({
        title: `进入${menuItem.name}`,
        icon: 'none'
      });
    }
  },

  onTabTap(e: any) {
    const page = e.currentTarget.dataset.page;
    Navigation.switchTab('profile', page);
  }
});